home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
nacs.arc
/
NASIFACE.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-09-26
|
6KB
|
353 lines
;/* NASIFACE.ASM
;*
;* NASI interFACE function calls
;*
;* ARGUMENT:
;*
;*
;* DESRCIPTION:
;*
;*
;* RETURNS:
;*
;*
;* AUTHOR:
;* Kamy Rahimi 17-JUN-1989 14:33:19.84
;* Copyright (C) 1989 Novell, Inc. CPD
;*
;*
;* MODIFICATIONS:
;*
;*/
.MODEL SMALL,C
.DATA
PortNumber DB 0
NASI_INIT_BUF DB 14 DUP (0)
NASI_REQUEST_BUF DB 13 DUP (0)
NASI_REPLY_BUF DB 13 DUP (0)
MatchPattern DB 30 DUP (0)
.CODE
;/*************************************************************/
; This routine checks to see if NASI is loaded - DOS 21H
;
; int IsNasiLoaded (void)
;
PUBLIC IsNasiLoaded
_NAME DB "NCSI"
IsNasiLoaded PROC
PUSH BP
MOV BP, SP
PUSH DS
PUSH SI
PUSH DI
PUSH CS ; DS=CS
POP DS
MOV AX, 356BH ; Get address of int vector
INT 21H
; Now ES:BX contains the CS:IP int vector for NASI
MOV DI, BX
LEA DI, [BX+3] ; ES:DI points to start of NASI string
MOV SI, OFFSET _NAME ; DS:SI points to "NASI"
MOV CX, 4 ; COUNT
CLD ; Clear the flags
XOR AX, AX
REPE CMPSB ; Compare the strings
JNE NOT_LOADED ; If the string doesn't compare
INC AX ; TRUE return code
NOT_LOADED:
POP DI
POP SI
POP DS
POP BP
RET
IsNasiLoaded ENDP
;/**************************************************************/
; This routine allocates a virtual circuit - function 11h
;
; char AllocateCircuit (void)
;
; returns: Virtual Circuit Number
;
PUBLIC AllocateCircuit
AllocateCircuit PROC
PUSH BP
MOV BP, SP
MOV AH, 11H
MOV AL, 0
INT 6BH
JC NASI_ERR01
XOR AH, AH
JMP SHORT OK
NASI_ERR01:
MOV AX, -1 ; Error
OK:
POP BP
RET
AllocateCircuit ENDP
;/**************************************************************/
; This routine queries the name services to find and return
; a port name record - function 21H
;
; NACSPort far *QueryName (VirtualCircuitNumber, NACSPort far *)
;
PUBLIC QueryName
QueryName PROC
PUSH BP
MOV BP, SP
MOV AL, [BP+4] ; 1st Arg.
PUSH DS
POP ES
MOV BX, [BP+6] ; 2nd Arg. is the port pattern struct
MOV AH, 21H
MOV CL, 0H ; Sets service name
; ES:BX Request match pattern
MOV CL, 0
INT 6BH
JC NASI_ERR02
; ES:BX Request data
MOV DX, ES
MOV AX, BX ; The port pattern
JMP SHORT GO_ON
NASI_ERR02:
MOV AX, -1 ; Error
GO_ON:
POP BP
RET
QueryName ENDP
;/****************************************************************/
; This routine allows you to set or get the port parameters i.e.
; baud rate, parity,... - funtion 15H
;
; int VirtualCircuitConfig (VirtualCircuitNumber, ConfigBuff, option)
;
; option = 1 set configuration
; 0 get configuration
;
PUBLIC VirtualCircuitConfig
VirtualCircuitConfig PROC
PUSH BP
MOV BP, SP
MOV AL, [BP+4] ; 1st Arg.
PUSH DS
POP ES
MOV BX, [BP+6] ; 2nd Arg.
MOV CL, [BP+8] ; set or get the config
MOV AH, 15H
; ES:BX Addres of request or reply buffer
INT 6BH
JC NASI_ERR03
; ES:BX Request data
NASI_ERR03:
MOV AX, -1 ; Error
POP BP
RET
VirtualCircuitConfig ENDP
;/****************************************************************/
; This routine initializes the given virtual circuit -
; function 16H
;
; int InitVirtualCircuit (VirtualCircuitNumber, NACSPort far *)
;
;
PUBLIC InitVirtualCircuit
InitVirtualCircuit PROC
PUSH BP
MOV BP, SP
MOV AL, [BP+4] ; 1st Arg
PUSH DS
POP ES
MOV BX, [BP+6] ; 2nd Arg. is the port pattern struct
MOV AH, 16H
XOR BX, BX
INT 6BH
JC NASI_ERR08
MOV PortNumber, AL
JMP SHORT OK_INIT
NASI_ERR08:
MOV AX, -1 ; CL contains the error 15h or feh
OK_INIT:
POP BP
RET
InitVirtualCircuit ENDP
;/**************************************************************/
; This routine checks the receive status - function 1AH
;
; int RXStatus (VirtualCircuitNumber)
;
;
PUBLIC RXStatus
RXStatus PROC
PUSH BP
MOV BP, SP
MOV AH, 1AH
MOV AL, [BP+4] ; 1st Arg.
INT 6BH
JNC STAT_OK
MOV AX, -1
STAT_OK:
POP BP
RET
RXStatus ENDP
;/**************************************************************/
; This routine reads x number of bytes - function 19H
;
; int NASIRead (VirtualCircuitNumber, ReceiveBuff, x)
;
;
PUBLIC NASIRead
NASIRead PROC
PUSH BP
MOV BP, SP
MOV AL, [BP+4] ; 1st Arg.
PUSH DS
POP ES
MOV BX, [BP+6] ; 2rd Arg. is input buffer
MOV CX, [BP+8] ; 3nd Arg. is NumberOfChars
MOV AH, 19H
INT 6BH
JC NASI_ERR05 ; Error if CX is zero
MOV AX, CX ; CX contains number of written chars
JMP SHORT OK_READ
NASI_ERR05:
XOR AX, AX
OK_READ:
POP BP
RET
NASIRead ENDP
;/**************************************************************/
; This routine checks the transmit status - function 1BH
;
; int TXStatus (VirtualCircuitNumber)
;
;
PUBLIC TXStatus
TXStatus PROC
PUSH BP
MOV BP, SP
MOV AH, 1BH
MOV AL, [BP+4] ; 1st Arg.
INT 6BH
JNC TX_STAT_OK
MOV AX, -1
TX_STAT_OK:
POP BP
RET
TXStatus ENDP
;/**************************************************************/
; This routine writes x number of bytes - funtion 18H
;
; int NASIWrite (VirtualCircuitNumber, TransmitBuff, x)
;
;
PUBLIC NASIWrite
NASIWrite PROC
PUSH BP
MOV BP, SP
MOV AL, [BP+4] ; 1st Arg.
PUSH DS
POP ES
MOV BX, [BP+6] ; 2rd Arg is input buffer
MOV CX, [BP+8] ; 3nd Arg is NumberOfChars
MOV AH, 18H
INT 6BH
JC NASI_ERR04 ; Error if CX=0
MOV AX, CX ; CX contains number written chars
JMP SHORT OK_WRITE
NASI_ERR04:
MOV AX, -1
OK_WRITE:
POP BP
RET
NASIWrite ENDP
;/**************************************************************/
; This routine disconnects the virtual circuit from the
; NACS server - function 17H
;
; int NASIDisconnect (VirtualCircuitNumber)
;
;
PUBLIC NASIDisconnect
NASIDisconnect PROC
PUSH BP
MOV BP, SP
MOV AH, 17H
MOV AL, [BP+4] ; 1st Arg.
INT 6BH
CMP AL, 0H
JE DISC_OK
MOV AX, -1
DISC_OK:
POP BP
RET
NASIDisconnect ENDP
END